﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace PromotionEngine
{
    public partial class Upload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = -1;
            try
            {
                if (Request.ContentLength > 0)
                {
                    HttpPostedFile postedFile = Request.Files[0];
                    if (postedFile != null)
                    {
                        // Save File
                        string savepath = Server.MapPath(Utils.Utils.IMPORT_PATH);
                        if (!Directory.Exists(savepath))
                            Directory.CreateDirectory(savepath);
                        postedFile.SaveAs(savepath + Utils.Utils.IMPORT_FILENAME);
                    }
                    Response.ContentType = "application/json";
                    Response.Write("{}");
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
    }
}